package com.taotao.rest.test;

import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.impl.HttpSolrServer;
import org.apache.solr.common.SolrInputDocument;
import org.junit.Test;
public class SolrJTset {
	@Test
	public void addDocumet() throws Exception{
		//创建一连接
		SolrServer solrServer=new HttpSolrServer("http://192.168.43.23:8080/solr");
		//创建一个文档对象
		SolrInputDocument document=new SolrInputDocument();
		document.addField("id", "tset01");
		document.addField("item_title", "测试商品2");
		document.addField("item_price", 54321);
		//把文档对象写入索引库
		solrServer.add(document);
		//提交
		solrServer.commit();
	}
	@Test
	public void delDocument() throws Exception{
		SolrServer solrServer=new HttpSolrServer("http://192.168.43.23:8080/solr");
		//solrServer.deleteById("tset01");
		solrServer.deleteByQuery("*:*");
		solrServer.commit();
	}

}
